home *** CD-ROM | disk | FTP | other *** search
/ Creative Computers / Creative Computers CD-ROM, Volume 1 (Legendary Design Technologies, Inc.)(1994).iso / shareware / telecom / term_4.1 / extras / hydracom / source / async.asm < prev    next >
Assembly Source File  |  1994-11-17  |  24KB  |  741 lines

  1. ;==============================================================================
  2. ;
  3. ;                             HydraCom Version 1.00
  4. ;
  5. ;                        A sample implementation of the
  6. ;                  HYDRA Bi-Directional File Transfer Protocol
  7. ;
  8. ;                            HydraCom was written by
  9. ;                  Arjen G. Lentz, LENTZ SOFTWARE-DEVELOPMENT
  10. ;                 COPYRIGHT (C) 1991-1993; ALL RIGHTS RESERVED
  11. ;
  12. ;                      The HYDRA protocol was designed by
  13. ;                Arjen G. Lentz, LENTZ SOFTWARE-DEVELOPMENT and
  14. ;                            Joaquim H. Homrighausen
  15. ;                 COPYRIGHT (C) 1991-1993; ALL RIGHTS RESERVED
  16. ;
  17. ;
  18. ; Revision history:
  19. ; 06 Sep 1991 - (AGL) First tryout
  20. ; .. ... .... - Internal development
  21. ; 11 Jan 1993 - HydraCom version 1.00, Hydra revision 001 (01 Dec 1992)
  22. ;
  23. ;
  24. ; For complete details of the Hydra and HydraCom licensing restrictions,
  25. ; please refer to the license agreements which are published in their entirety
  26. ; in HYDRACOM.C and LICENSE.DOC, and also contained in the documentation file
  27. ; HYDRACOM.DOC
  28. ;
  29. ; Use of this file is subject to the restrictions contained in the Hydra and
  30. ; HydraCom licensing agreements. If you do not find the text of this agreement
  31. ; in any of the aforementioned files, or if you do not have these files, you
  32. ; should immediately contact LENTZ SOFTWARE-DEVELOPMENT and/or Joaquim
  33. ; Homrighausen at one of the addresses listed below. In no event should you
  34. ; proceed to use this file without having accepted the terms of the Hydra and
  35. ; HydraCom licensing agreements, or such other agreement as you are able to
  36. ; reach with LENTZ SOFTWARE-DEVELOMENT and Joaquim Homrighausen.
  37. ;
  38. ;
  39. ; Hydra protocol design and HydraCom driver:         Hydra protocol design:
  40. ; Arjen G. Lentz                                     Joaquim H. Homrighausen
  41. ; LENTZ SOFTWARE-DEVELOPMENT                         389, route d'Arlon
  42. ; Langegracht 7B                                     L-8011 Strassen
  43. ; 3811 BT  Amersfoort                                Luxembourg
  44. ; The Netherlands
  45. ; FidoNet 2:283/512, AINEX-BBS +31-33-633916         FidoNet 2:270/17
  46. ; arjen_lentz@f512.n283.z2.fidonet.org               joho@ae.lu
  47. ;
  48. ; Please feel free to contact us at any time to share your comments about our
  49. ; software and/or licensing policies.
  50. ;
  51. ;==============================================================================
  52.  
  53.  
  54.           IDEAL
  55.  
  56. IFDEF MODL
  57.           MODEL MODL
  58. ELSEIFDEF _SMALL
  59.           MODEL SMALL
  60. ELSEIFDEF _LARGE
  61.           MODEL LARGE
  62. ENDIF
  63.  
  64.  
  65. EOI             equ     020h                    ; 8259 end-of-interupt
  66. Ctrl8259_0      equ     020h                    ; 8259 port
  67. Ctrl8259_1      equ     021h                    ; 8259 port (Masks)
  68. BufSize         equ     4100                    ; Buffer Size
  69.  
  70.  
  71.  
  72.  
  73.         DATASEG
  74.  
  75. ; Various things to be set upon AsyncInit()
  76. VectorNum       db      ?                       ; Vector Number
  77. EnableIRQ       db      ?                       ; Mask to enable 8259 IRQ
  78. DisableIRQ      db      ?                       ; Mask to disable 8259 IRQ
  79. VectorSeg       dw      ?                       ; Old Vector Segment
  80. VectorOfs       dw      ?                       ; Old Vector Offset
  81.  
  82. Fifo            db      ?                       ; Nonzero if 16550 FIFO enabled
  83. CTShand         dw      ?                       ; Nonzero if CTS handshaking ok
  84.  
  85. ; Register Addresses for the 8250 UART
  86. Port            dw      ?                       ; Port Base Address
  87. LABEL RegStart word
  88. THR             dw      ?                       ; Transmitter Holding Register
  89. RDR             dw      ?                       ; Receiver Data Register
  90. BRDL            dw      ?                       ; Baud Rate Divisor, Low byte
  91. BRDH            dw      ?                       ; Baud Rate Divisor, High Byte
  92. IER             dw      ?                       ; Interupt Enable Register
  93. IIR             dw      ?                       ; Interupt Identification Reg
  94. FCR             dw      ?                       ; FIFO Control Register
  95. LCR             dw      ?                       ; Line Control Register
  96. MCR             dw      ?                       ; Modem Control Register
  97. LSR             dw      ?                       ; Line Status Register
  98. MSR             dw      ?                       ; Modem Status Register
  99. ; Register Offsets for the UART
  100. RegOffsets      dw      0, 0, 0, 1, 1, 2, 2, 3, 4, 5, 6
  101.  
  102. ; Buffer Data
  103. RecBuffer       db      BufSize DUP (?)         ; Receive Buffer
  104. RecHead         dw      ?                       ; Buffer Head Pointer
  105. RecTail         dw      ?                       ; Buffer Tail Pointer
  106. TransBuffer     db      BufSize DUP (?)         ; Transmit Buffer
  107. TransHead       dw      ?                       ; Buffer Head Pointer
  108. TransTail       dw      ?                       ; Buffer Tail Pointer
  109.  
  110.  
  111.         CODESEG
  112.  
  113.         PUBLIC  _AsyncInit,     _AsyncDump,     _AsyncPurge,    _AsyncStop
  114.         PUBLIC  _AsyncIn,       _AsyncOut,      _AsyncSet
  115.         PUBLIC  _AsyncHand,     _AsyncStat,     _AsyncInStat
  116.         PUBLIC  _AsyncOutStat,  _AsyncCTS,      _AsyncFifo
  117.  
  118.  
  119. ;-----------------------------------------------------------------------------
  120. ; AsyncDump                                          Empty the transmit buffer
  121. ;-----------------------------------------------------------------------------
  122. ; void  AsyncDump (void);
  123. ;
  124. ;
  125. ;-----------------------------------------------------------------------------
  126. PROC    _AsyncDump
  127.         cli
  128.         push    ax
  129.         mov     ax, offset TransBuffer
  130.         mov     [TransHead], ax
  131.         mov     [TransTail], ax
  132.         pop     ax
  133.         sti
  134.         ret
  135. ENDP    _AsyncDump
  136.  
  137.  
  138.  
  139. ;-----------------------------------------------------------------------------
  140. ; AsyncPurge                                          Empty the receive buffer
  141. ;-----------------------------------------------------------------------------
  142. ; void  AsyncPurge (void);
  143. ;
  144. ;
  145. ;-----------------------------------------------------------------------------
  146. PROC    _AsyncPurge
  147.         cli
  148.         push    ax
  149.         mov     ax, offset RecBuffer
  150.         mov     [RecHead], ax
  151.         mov     [RecTail], ax
  152.         pop     ax
  153.         sti
  154.         ret
  155. ENDP    _AsyncPurge
  156.  
  157.  
  158.  
  159. ;-----------------------------------------------------------------------------
  160. ; AsyncInit                              Initalize Serial Port and install ISR
  161. ;-----------------------------------------------------------------------------
  162. ;       void    AsyncInit( int port)
  163. ;
  164. ;       Where Port is
  165. ;               0  =  COM1
  166. ;               1  =  COM2
  167. ;               2  =  COM3
  168. ;               3  =  COM4
  169. ;
  170. ;-----------------------------------------------------------------------------
  171. PROC    _AsyncInit
  172.         ARG     CommPort:word
  173.  
  174.         push    bp
  175.         mov     bp, sp
  176.  
  177. ;---- Set various things according to com port number
  178.         mov     ax, [CommPort]
  179.  
  180. ;----- COM1
  181.         cmp     ax, 0
  182.         jne     @@1
  183.         mov     [Port], 03F8h
  184.         mov     [VectorNum], 0Ch
  185.         mov     [EnableIRQ], 0EFh
  186.         mov     [DisableIRQ], 10h
  187.         jmp     short @@Done
  188. @@1:
  189. ;----- COM2
  190.         cmp     ax, 1
  191.         jne     @@2
  192.         mov     [Port], 02F8h
  193.         mov     [VectorNum], 0Bh
  194.         mov     [EnableIRQ], 0F7h
  195.         mov     [DisableIRQ], 08h
  196.         jmp     short @@Done
  197. @@2:
  198. ;----- COM3
  199.         cmp     ax, 2                           ; 2
  200.         jne     @@3
  201.         mov     [Port], 03E8h                   ; 03E8
  202.         mov     [VectorNum], 0Ch                ; 0C
  203.         mov     [EnableIRQ], 0EFh               ; EF
  204.         mov     [DisableIRQ], 10h               ; 10
  205.         jmp     short @@Done
  206. @@3:
  207. ;----- COM4
  208.         mov     [Port], 02E8h                   ; 02E8
  209.         mov     [VectorNum], 0Bh                ; 0B
  210.         mov     [EnableIRQ], 0F7h               ; F7
  211.         mov     [DisableIRQ], 08h               ; 08
  212. @@Done:
  213.  
  214. ;---- Compute Register locations
  215.         mov     cx, 11
  216.         mov     bx, offset RegOffsets
  217.         push    di
  218.         mov     di, offset RegStart
  219. @@4:
  220.         mov     ax, [bx]
  221.         add     ax, [Port]
  222.         mov     [di], ax
  223.         add     bx, 2
  224.         add     di, 2
  225.